// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// 设置 js中可以访问 $cdn
import { $cdn } from '@/config'
Vue.prototype.$cdn = $cdn
Vue.prototype.$clientHeight = document.body.clientHeight || document.documentElement.clientHeight

// 全局引入按需引入UI库 vant
import '@/plugins/vant'
// 引入全局样式
import '@/assets/css/index.scss'

import '@/assets/css/toast.css'
// 移动端适配
import 'lib-flexible/flexible.js'

// import VConsole from 'vconsole'
// new VConsole();

console.log("123")

// localStorage.setItem('token', 'EXPRESS-H5-REGISTER')
// filters
import './filters'
Vue.config.productionTip = false

import './permission'

// 手动按公众号 页面设置的刷新 会触发 main.js 不会触发 ./permission

import { isBind } from "./sgApi/index.js"

(function checkIsBind() {



  if (localStorage.getItem("obj")) {
    let openid = JSON.parse(localStorage.getItem("obj")).openid || ""
    // 测试流程 用
    isBind({
      openid
    }).then(res => {

      localStorage.setItem("customerCrmId", res.customerCrmId)

      if (res.isCustomerBind == 1) {
        // setTimeout(() => {
        //   router.replace({
        //     path: "/memberCenter"
        //   })
        // }, 400);

      } else {
        // setTimeout(() => {
        //   router.replace({
        //     path: "/login"
        //   }).catch(err => { console.log(err) })
        // }, 400);


      }

    })
  }


})()




new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
